package com.andnnl.table;

import cn.hutool.core.util.StrUtil;

/**
 * Created by chenss on 2021/7/8.
 */
public class GenCreateIndexStrTest {
    public static void main(String[] args) {
        test1();
//        test2();
    }

    private static void test1() {
        String fmt="USE [EMAS_SMS_MC_{}]\n" +
                "GO\n" +
                "\n" +
                "CREATE NONCLUSTERED INDEX [idx_eprid_sendtime] ON [dbo].[TBL_SMS_CONTENT_{}]\n" +
                "(\n" +
                "\t[EPRID] ASC,\n" +
                "\t[SENDTIME] ASC\n" +
                ")WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n" +
                "GO\n" +
                "\n" +
                "\n";
        //TBL_SMS_LONG_MSGID_202008_61
        for (int i = 202101; i <= 202112; i++) {
//            for (int j = 0; j <= 99; j++) {
//                String s = "drop table TBL_SMS_LONG_MSGID_" + i + "_" + fm(j) + ";";
                System.out.println(StrUtil.format(fmt,i,i));
//            }
        }
    }

    private static String fm(int j) {
        return j < 10 ? "0" + j : ""+j;
    }

    private static void test2() {
        //TBL_SMS_LONG_MSGID_202008_61
        for (int j = 0; j <= 99; j++) {
            String aa = j < 10 ? "0" + j : ""+j;
            String s = "delete FROM [EMAS_SMS].[dbo].[TBL_SMS_LONG_MSGID_" + aa + "] where [createTime] < '2021-01-01';";
            System.out.println(s);
        }
    }
}
